package com.xhs.config;

import com.xhs.interceptor.LoggingInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @desc: 拦截器配置
 * @projectName: mybatis-flex-demo
 * @author: xhs
 * @date: 2025-01-16 周四 16:34
 * @version: JDK 1.8
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Resource
    private LoggingInterceptor loggingInterceptor;

    /**
     * 注册拦截器
     *
     * @param registry 入参
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册日志拦截器
        registry.addInterceptor(loggingInterceptor).addPathPatterns("/**");
    }
}
